from OpenGL.GL import *
from OpenGL.GLUT import *

from common import *
from common.terrain import Block
from common.manager import Manager
from . import AbstractBuilding

class Workopolis(AbstractBuilding):
	"""
	Workopolis building.
	"""
	
	MAX_HP = 10000
	SIZE = [3, 3]
	
	def __init__(self, block, team):
		super(Workopolis, self).__init__(Workopolis.SIZE, block, 
										team, Workopolis.MAX_HP)
		
		self.side = Block.SIZE * 0.5  
		
	def render(self, alpha=None):
		glPushMatrix()
		
		glTranslate(*self.middle)
		
		glTranslate(0, 0, self.side)
		if alpha is None: glColor(1, 1, 1)
		else: glColor(1, 1, 1, alpha)
			
		glEnable(GL_TEXTURE_2D)
		glBindTexture(GL_TEXTURE_2D, Manager.textures['squares'])
		glutSolidCube(self.side * 3.8)
		glTranslate(0, 0, 1.9 * self.side)
		
		if self.team == BLUE:
			if alpha is None:
				glColor(0.4, 0.4, 1.0)
			else:
				glColor(0.4, 0.4, 1.0, alpha)
		elif self.team == YELLOW:
			if alpha is None:
				glColor(1.0, 1.0, 0.4)
			else:
				glColor(1.0, 1.0, 0.4, alpha)

		glutSolidSphere(1.9 * self.side, 10, 10)
		glDisable(GL_TEXTURE_2D)
		
		glPopMatrix()
		
	def render_picking(self):
		pass